package com.hdoit.ares.logical.acti.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.hdoit.ares.logical.acti.dao.IActiTaskDao;
import com.hdoit.ares.logical.acti.model.ActiTask;
import com.hdoit.ares.logical.viewmodel.acti.ActiTaskSearch;
import com.hdoit.ares.selfcommon.enums.acti.ActiState;
import com.hdoit.ares.selfcommon.enums.acti.TaskType;
import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.enums.OrderEnum;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.FinderExpressionFactory;
/**
 * @author      caochengmeng
 * @email       
 * @createtime  2018年03月14日 08:40:25
 * @comment
 */
@Component
public class ActiTaskDaoImpl extends SuperDao<ActiTask> implements IActiTaskDao{

	@Override
	public List<ActiTask> queryListDayTask() {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(ActiTask.class)
						.andEq("confirmState","confirmed")
						.andEq("taskState",ActiState.up)
						.andEq("taskType",TaskType.dayTask)
						.addOrder("createDate", OrderEnum.asc);
		return queryList(finderExpression);
	}
	
	@Override
	public List<ActiTask> queryListWeekTask() {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(ActiTask.class)
						.andEq("confirmState","confirmed")
						.andEq("taskState",ActiState.up)
						.andEq("taskType",TaskType.weekTask)
						.addOrder("createDate", OrderEnum.asc);
		return queryList(finderExpression);
	}
	
	@Override
	public List<ActiTask> queryListMonthTask() {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(ActiTask.class)
						.andEq("confirmState","confirmed")
						.andEq("taskState",ActiState.up)
						.andEq("taskType",TaskType.monthTask)
						.addOrder("createDate", OrderEnum.asc);
		return queryList(finderExpression);
	}
	
	@Override
	public List<ActiTask> queryList(PagerModel pagerModel,ActiTaskSearch search) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(ActiTask.class)
						.andEq("confirmState","confirmed")
						.andEq("taskState",ActiState.up)
						.andEq("taskType",TaskType.monthTask)
						.addOrder("createDate", OrderEnum.asc);
		return queryList(finderExpression ,pagerModel);
	}
	
	@Override 
	public ActiTask queryModelByTaskId(String taskId){
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("*")
						.from(ActiTask.class)
						.andEq("confirmState","confirmed")
						.andEq("taskState",ActiState.up)
						.andEq("taskId",taskId)
						.addOrder("createDate", OrderEnum.asc);
		return queryModel(finderExpression);
	}
}